package kamkor.webtoolseditor;

import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.apache.wicket.extensions.ajax.markup.html.autocomplete.DefaultCssAutocompleteTextField;
import org.apache.wicket.model.IModel;
import org.apache.wicket.util.string.Strings;

import scala.actors.threadpool.Arrays;

/**
 * TextField that displays suggestions
 * 
 * @author kamkor
 *
 */
public class CustomAutoCompleteTextField extends DefaultCssAutocompleteTextField<String> {
	
	private String[] autoCompleteSuggestions;
	
	public CustomAutoCompleteTextField(String string, IModel<String> model, String[] autoCompleteSuggestions) {
		super(string, model);
		this.autoCompleteSuggestions = autoCompleteSuggestions;		
	}
	
	@Override
	protected Iterator<String> getChoices(String input) {		
		if(Strings.isEmpty(input)) {
			List<String> emptyList = Collections.emptyList();
            return emptyList.iterator();
		}
		return Arrays.asList(autoCompleteSuggestions).iterator();		
	}
	
}
